package com.xinqi.xinqidev.bigmodel.gptutils;


import com.xinqi.xinqidev.bigmodel.entity.RoleContent;

import java.util.List;

/**
 * @author xin麒
 * @date 2023/12/12 15:05
 */
public class HistoryUtils {
    public static boolean canAddHistory(List<RoleContent> historyList) {  // 由于历史记录最大上线1.2W左右，需要判断是能能加入历史
        int size = 0;
        for (RoleContent temp : historyList) size += temp.getContent().length();

        if (size > 12000) {
            historyList.remove(0);
            historyList.remove(1);
            historyList.remove(2);
            historyList.remove(3);
            historyList.remove(4);
            return false;
        } else {
            return true;
        }
    }
}
